<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>img居中</title>
    <style>
        .box, .img {
            width: 1000px;
            height: 500px;
            border: 1px solid #ccc;
            margin: 0 auto;
            margin-bottom: 50px;
        }
        /*img*/
        .box img {
            width: 1000px;
            height: 500px;
            object-fit: cover;
        }
        /*background*/
        .img {
            background-image: url("20190913211905387329.jpg");
            background-repeat: no-repeat;
            background-position:center center;
            background-size: cover;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>img方式</h1>
        <div class="box">
            <img src="20190913211905387329.jpg" alt="">
        </div>
        <h1>background方式</h1>
        <div class="img"></div>
    </div>
</body>
</html>
